#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int a, b;
        a = b = 0;
        for (auto x : nums)
        {
            int a_tmp = a;
            a = (a ^ x) & (a | b);
            b = (b ^ x) & (~a_tmp);
        }
        return b;
    }
};

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int n = 0;
        for (auto i : nums)
        {
            n ^= i;
        }
        int tmp = (n == INT_MIN ? INT_MIN : n & -n);
        int a, b;
        a = b = 0;
        for (auto i : nums)
        {
            if (i & tmp)
            {
                a ^= i;
            }
            else
            {
                b ^= i;
            }
        }
        return { a, b };
    }
};